package cn.kgc.tangcco.inherit06;

/**
 * @author 李昊哲
 * @Description
 * @create 2020/8/20 上午11:01
 */
class Super{
    public void f(){
        System.out.println("Super.f()");
    }
}
class Sub extends Super{
    public void f(){
        System.out.println("Sub.f()");
    }
}
class Goo {
    public void g(Super obj){
        System.out.println("g(Super)..");
        obj.f();
    }
    public void g(Sub obj){
        System.out.println("g(Sub)..");
        obj.f();
    }
}
public class InheritTest {
    public static void main(String[] args){
        Super s = new Sub();
        Goo goo = new Goo();
        goo.g(s);
        // 输出结果为：g(Super)..   Sub.f()
        // 结论：重载看类型，重写看对象
    }
}
